package app.netant.bt.bthuahua;

import org.jsoup.select.Elements;

import app.netant.bt.MargnetDetail;
import app.netant.bt.MargnetEntity;
/**
 * www.bthuahua.net
 * @author JiaJ
 *
 */
public class BtHuaHuaDetail extends MargnetDetail {
	
	public BtHuaHuaDetail(String netSite) {
		super(netSite);
	}
	
	private void analyseName(){
		Elements activePart = document.select(".wrap .container h3");
		if(activePart.size()>0){
			this.entity.setMargnetName(activePart.get(0).text());
		}
	}
	
	private void analyseDate(){
		Elements activePart = document.select(".wrap .container h4 span.label.label-success");
		if(activePart.size()>0){
			this.entity.setMargnetDate(activePart.get(0).text());
		}
	}
	
	private void analyseSize(){
		Elements activePart = document.select(".wrap .container h4 span.label.label-warning");
		if(activePart.size()>0){
			this.entity.setMargnetSize(activePart.get(0).text());
		}
	}
	
	private void analyseMargnet(){
		Elements activePart = document.select(".wrap .container #magnet a");
		if(activePart.size()>0){
			this.entity.setMargnetURL(activePart.get(0).text());
		}
	}
	
	private void analyseFileList(){
		Elements activePart = document.select(".wrap .container #file-list li");
		StringBuffer sb = new StringBuffer();
		for(int i=0;i<activePart.size();i++){
			sb.append(activePart.get(0).text()+"\n");
		}
		this.entity.setMargnetFile(sb.toString());
	}
	
	public void analyse(){
		this.analyseName();
		this.analyseDate();
		this.analyseSize();
		this.analyseMargnet();
		this.analyseFileList();
	}
	
	public static void main(String[] args) {
		BtHuaHuaDetail detail = new BtHuaHuaDetail("https://www.bthuahua.net/index.php?r=files/view&infohash=59c936a688e2889459b0679bfc9edfc0e30db3b8");
		detail.analyseName();
		detail.analyseDate();
		detail.analyseSize();
		detail.analyseMargnet();
		detail.analyseFileList();
	}

}
